<script type="text/javascript">
	function HidePart(item) { 
		document.getElementById(item).style.display = "none";
		}
	function ShowPart(item) { 
		document.getElementById(item).style.display = "inline-block"; 
	}
	
	//$(document).ready(function() {
	//	$(".tasklist-container").each(function() {
	//		$(this).mouseover(function() {
	//			$(this).children("tasklistControl").show();
	//		});
	//		$(this).mouseout(function() {
	//			$(this).children("tasklistControl").hide();
	//		});
	//	});
	// });
</script>

<?php
    $jsShowTaskList = "
        function ShowTaskList(tasklistid){
            $(\".tasklist-container\").not(\"#tasklist-container-\"+tasklistid).hide();
            $(\"#tasklist-container-\"+tasklistid).show();
            return false;
        }
    ";
    
    $jsDelEditTaskRow = "
        $(\".taskRow\").mouseover(function(){
            $(this).find(\".taskControl\").show();
        });
        $(\".taskRow\").mouseout(function(){
            $(this).find(\".taskControl\").hide();
        });
        $(\".tasklist-container\").mouseover(function(){
            $(this).find(\".tasklistControl\").show();
        });
        $(\".tasklist-container\").mouseout(function(){
            $(this).find(\".tasklistControl\").hide();
        });
    ";
    
    $jsHideCompleteTask = "
        $(\".taskcomplete\").hide();
    ";
    
    $jsFilterUser = "
        $(\"#filterUser\").change(function()
        {
            document.location.href = $(this).val();
        });
    ";
    Yii::app()->clientScript->registerScript('ShowTaskList',$jsShowTaskList,CClientScript::POS_HEAD);
    Yii::app()->clientScript->registerScript('DelEditTaskRow',$jsDelEditTaskRow,CClientScript::POS_READY);
    Yii::app()->clientScript->registerScript('HideCompleteTask',$jsHideCompleteTask,CClientScript::POS_READY);
    Yii::app()->clientScript->registerScript('FilterUser',$jsFilterUser,CClientScript::POS_READY);
?>

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/task.css" />
<link rel='stylesheet' type='text/css' href="<?php echo Yii::app()->theme->baseUrl; ?>/css/jquery-ui-1.8.14.custom.css" />
<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/fullCalendar/jquery/jquery-ui-1.8.11.custom.min.js"></script>
<script type='text/javascript' src="<?php echo Yii::app()->theme->baseUrl; ?>/js/jquery.ui.datepicker.js"></script>

<script type="text/javascript">
	$(document).ready(function(){
		
		
		$('.addTaskTime').datepicker({
				dateFormat: 'yy-mm-dd'
		});
		$('.editTaskTime').datepicker();
		//Close Fancybox
		
		
		$('input:checkbox').click(function(){
		
			//if($(this).is(':checked')){
			
			var value = $(this).val();
			var listPeople = '';
			var count = 0;
			$('input:checkbox:checked').each(function() {
				
				listPeople = listPeople + $(this).val();
				listPeople = listPeople +',';
				count++;
			})
			$("#listPeople").val(''+count+ 'persons ');
			listPeople = '';
			})
			//Close button
			$('#clear').click(function(){
					$("#addTask").fancybox();
					$('input:checkbox:checked ').each(function() {
						$('input:checkbox').attr('checked',false);
						count = 0;
						$("#listPeople").val(''+count+ 'persons ');
						
					})
				})
				//All None
				$('#all').click(function(){
					
						$('input:checkbox').attr('checked',true);
						count = 0;
						$("#listPeople").val(''+count+ 'persons ');
				
				})
				$('#none').click(function(){
					
						$('input:checkbox').attr('checked',false);
						count = 0;
						$("#listPeople").val(''+count+ 'persons ');
				})
		})
</script>
<div class="padding5"></div>
<div id="leftSidebar">
				<div id="leftWrapper">
					<h2>New task lists</h2>           		
            		<div class="padding15"></div>
            		
                            <!-- List all user in select box -->
                            
            		<div class="padding15"></div>
                        <a href="#" onclick="javascript:$('.tasklist-container').show()">Active task lists</a>
            		<div class="padding5"></div>
            		
				</div>
			</div>
<div id="rightSidebar">
       <div id="rightHeader">
			<h2>Tasks</h2>
	  </div>
	  <div id="rightWrapper">	
	 	 <div id = "editTaskTitle">
	 			<font> Edit task 1</font>
	 	 </div>	
	 	 <div id ="contentWrapper">
		<h3>What needs to be done?</h3>
		<div class="padding5"></div>
		<?php 
		$pid = Yii::app()->request->getParam("pid");
		$tid = Yii::app()->request->getParam("tid");
		$form = $this->beginWidget('CActiveForm',array(
			'id'=>'edit-task',
    		'enableAjaxValidation'=>true,
    		'enableClientValidation'=>true,
    		'action'=>array('/tasks/edit','pid'=>$pid),
		));
		echo Chtml::hiddenField('tid',$tid);
		echo $form->textField($editTask,'task_name',array(
			'class'=>"addTaskName",
			'style'=>"width: 60%",
		));
		echo $form->error($editTask,'task_name');
	?>
	
    		<div class="padding10"></div>	
    		<div id="priority">
    			<label>Priority</label> 
    			<?php echo Chtml::activeDropDownList($editTask, 'task_priority', $editTask->listPriority(),array('id'=>'task_priority')); ?>
    		</div>
    		<div class="padding10"></div>
    			<label>	Complete at ?</label>
    				
    				<?php 
    					echo $form->textField($editTask,'task_completed_date',array(
    						'class'=>"addTaskTime",
    						'style'=>"width: 15%;margin-right:40%",
    					));
    					echo $form->error($editTask,'task_completed_date');
    					
    					echo '
    						<div class="padding10"></div>
    						<label>Description</label>
    					';
    					echo $form->textArea($editTask,'task_description',array(
    						'rows'=>"4",
    						'cols'=>"70",
    						'style'=>"margin-right:40%",
    					));
    					echo '<div class="padding5"></div>';
    					echo '<div class="postButton">';
    						echo Chtml::submitButton("Save this task");
    						echo ' or ';
    						echo Chtml::link('Cancel',array('/tasks/index', 'pid'=>$pid), array('class'=>'popupCancel'));
    					echo '</div>';
    				?>
			<?php $this->endWidget();?>
		</div>	
	</div>
</div>